﻿using System.Collections;
using UnityEngine;

namespace Assets.XyzCode.Test
{
#if UNITY_EDITOR
    /// <summary>
    /// 测试场景
    /// </summary>
    public class TestScene : MonoBehaviour
    {
        /// <summary>
        /// Start
        /// </summary>
        void Start()
        {
            StartCoroutine(Test_XC());
        }

        /// <summary>
        /// 测试携程
        /// </summary>
        /// <returns>枚举迭代器</returns>
        IEnumerator Test_XC()
        {
            yield return new MyEnumerator();

            Debug.Log("Over");
            yield break;
        }

        /// <summary>
        /// 自定义枚举迭代器
        /// </summary>
        class MyEnumerator : IEnumerator
        {
            /** 计数器 */
            int _counter = 10;

            // @Override
            public object Current => 1;

            // @Override
            public bool MoveNext()
            {
                Debug.Log("MoveNext");
                return _counter-- > 0;
            }

            // @Override
            public void Reset()
            {
            }
        }
    }
#endif
}
